package util;


public class transFileUtils {

	public class information {
		
		public String serverIP;
		public int serverPort;
		public String userName;
		public String userPassword;
		public String encoding;
		public String fileType;
	}
	
	private String getPathPrefix(String remotePath) {
		
		String sRet = "";
		
		if(remotePath.startsWith("file://") || remotePath.startsWith("sftp://")) {
			sRet = remotePath.substring(7);
		} else if(remotePath.startsWith("ftp://")) {
			sRet = remotePath.substring(6);
		} else {
			sRet = remotePath;
		}
		
		return sRet;
	}

	public int upDownload(String remotePath, String localPath, boolean type) {
		int nRet = 0;
		
		String tmpRemotePath = getPathPrefix(remotePath);
		String tmplocalPath = localPath;
		
		if(remotePath.startsWith("file://")) {
			if(type) {
				nRet = driveFileCopy(tmplocalPath, tmpRemotePath);
			} else {
				nRet = driveFileCopy(tmpRemotePath, tmplocalPath);
			}
		} else if(remotePath.startsWith("ftp://")) {
			if(type) {
				nRet = ftpFileCopy(tmplocalPath, tmpRemotePath);
			} else {
				nRet = ftpFileCopy(tmpRemotePath, tmplocalPath);
			}
		} else if(remotePath.startsWith("sftp://")) {
			if(type) {
				nRet = sftpFileCopy(tmplocalPath, tmpRemotePath);
			} else {
				nRet = sftpFileCopy(tmpRemotePath, tmplocalPath);
			}
			
		}
		
		
		return nRet;
	}
	
	public int driveFileCopy(String srcFile, String dstFile) {
		return fileUtils.copyFile(srcFile, dstFile);
	}
	public int ftpFileCopy(String srcFile, String dstFile) {
		int nRet = 0;
		
		return nRet;
	}
	public int sftpFileCopy(String srcFile, String dstFile) {
		int nRet = 0;
		
		return nRet;
	}
}
